Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
I get "No matching signature" error in my background.js

I get the error "Uncaught TypeError: Error in invocation of scripting.executeScript(scripting.ScriptInjection injection, optional function callback): No matching signature." in my console. I have no idea what's wrong, someone please help me, I really appreciate it.

Here is the background.js code:

var Tabclicked = false;
disableBrowserAction();


function disableBrowserAction(tabId) {
    chrome.scripting.executeScript(tabId, { file: 'jquery.js' }, function() {
        chrome.scripting.executeScript(tabId, { file: 'CloseRuler.js' });
    });
}

function enableBrowserAction(tabId) {
    chrome.scripting.executeScript(tabId, { file: 'jquery.js' }, function() {
        chrome.scripting.executeScript(tabId, { files: 'Ruler.js' });
    });
}

function updateState() {
    if (Tabclicked == false) {
        Tabclicked = true;
        enableBrowserAction();
    } else {
        Tabclicked = false;
        disableBrowserAction();
    }
}

//chrome.pageAction.onClicked.addListener(updateState);

chrome.action.onClicked.addListener(function(tabId) {
    updateState(tabId);
    alert('File test alert');

});

alert('File test alert');

Here is my manifest:

{
    "name": "Physics Ruler",
    "description": "Position the ruler and measure the objects!",
    "version": "1.0",
    "manifest_version": 3,
    "permissions": [
        "activeTab",
        "scripting"
    ],
    "background": {
        "service_worker": "background.js",
        "type": "module"
    },
    "action": {
        "default_icon": "icon.png",
        "default_title": "Ruler",
        "name": "Physics Ruler"
    },
    "content_scripts": [{
        "js": ["jquery.js"],
        "matches": ["*://*/*"]
    }],
    "host_permissions": [
        "*://*/*"
    ]
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So, I have found the answer, and the documentation was kind of not help full, I have just tried different things until it worked.

We have to make this function with chrome tabs:

chrome.tabs.query({ currentWindow: true, active: true }, function(tabs) {

in that function then we can use "tabs[0].id" to get the id.

for example:

function enableBrowserAction(tabId) {
chrome.tabs.query({ currentWindow: true, active: true }, function(tabs) {
    chrome.scripting.executeScript({ target: { tabId: tabs[0].id }, files: ['jquery.js'] }, function() {
        chrome.scripting.executeScript({ target: { tabId: tabs[0].id }, files: ['Ruler.js'] });
    });
});

}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda